package com.molin.networkTest.socketTest.tcpTest.Demo4;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.Socket;

public class ClientDemo {
    public static void main(String[] args) throws IOException {
        //建立本地流
        String path="D:\\IdeaProjects\\BasicCode\\mIdeaTest\\src\\com\\molin\\networkTest\\socketTest\\tcpTest\\demo3\\feiniao.jpeg";
        BufferedInputStream bufferedInputStream=new BufferedInputStream(new FileInputStream(path));

        //建立网络流
        Socket socket=new Socket("127.0.0.1",8888);
//        OutputStream outputStream = socket.getOutputStream();
        BufferedOutputStream bo=new BufferedOutputStream(socket.getOutputStream());

        //边读边写，本地流===>网络流
        int b;
        while ((b=bufferedInputStream.read())!=-1){
            bo.write(b);
        }

        bufferedInputStream.close();
        bo.close();
        socket.close();
    }
}
